home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / unix / c / writev < prev   
Text File  |  1996-11-09  |  1KB  |  41 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/unix/c/RCS/writev,v $
  4.  * $Date: 1996/10/30 22:04:51 $
  5.  * $Revision: 1.1 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: writev,v $
  10.  * Revision 1.1  1996/10/30 22:04:51  unixlib
  11.  * Initial revision
  12.  *
  13.  ***************************************************************************/
  14.  
  15. static const char rcs_id[] = "$Id: writev,v 1.1 1996/10/30 22:04:51 unixlib Rel $";
  16.  
  17. /* unix.c.writev: Written by Nick Burrett, 6 October 1996.  */
  18.  
  19. #include <stddef.h>
  20. #include <unistd.h>
  21. #include <sys/uio.h>
  22.  
  23. /* Write data pointed by the buffers described by VECTOR, which
  24.    is a vector of COUNT `struct iovec's, to file descriptor FD.
  25.    The data is written in the order specified.  */
  26. int writev (int fd, const struct iovec *vector, size_t count)
  27. {
  28.   int bytes;
  29.   int i;
  30.  
  31.   bytes = 0;
  32.   for (i = 0; i < count; ++i)
  33.     {
  34.       i = write (fd, vector[i].iov_base, vector[i].iov_len);
  35.       if (i == -1)
  36.         return -1;
  37.       bytes += i;
  38.     }
  39.   return bytes;
  40. }
  41.